package clienteremoto;

import ejb.BeanSeguroRemoto;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;

public class ClienteRemoto {

    public static void main(String[] args) throws Exception {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial",
                "com.sun.enterprise.naming.SerialInitContextFactory");

        props.setProperty("java.naming.factory.url.pkgs",
                "com.sun.enterprise.naming");

        props.setProperty("java.naming.factory.state",
                "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");


        // optional.  Defaults to localhost.  Only needed if web server is running
        // on a different host than the appserver   
        props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");

        // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

        props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
        props.setProperty(Context.SECURITY_CREDENTIALS, "admin");

        Context ctx = new InitialContext(props);
        
        NamingEnumeration<NameClassPair> list = ctx.list("");
        while(list.hasMore()){
            System.out.println(list.next());
        }
        
//        BeanSeguroRemoto b = (BeanSeguroRemoto) ctx.lookup("java:global/SeguridadEJB/SeguridadEJB-ejb/BeanSeguro!ejb.BeanSeguroRemoto");

//        b.metodoPublico();

    }
}
